public class Solution14 {
    public String longestCommonPrefix(String[] strArray) {
        if (strArray.length == 0) {
            return "";
        }

        String common = "";
        String str = strArray[0];
        for (int i = 1; i <= str.length(); i++) {
            String t = str.substring(0, i);
            boolean flag = false;
            for (int j = 1; j < strArray.length; j++) {
                String s = strArray[j];
                if (!s.startsWith(t)) {
                    flag = true;
                    break;
                }
            }
            if (flag)
                break;
            common = t;
        }

        return common;
    }
}
